package com.googlecode.jreview;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

/// don't use for freakign anything, so incredibly basic.  just more proof-of-concept and the
/// start of a framework maybe?
public class MyWindow implements ActionListener {

	public static void main (String[] args) {
		MyWindow gui = new MyWindow ();
		gui.go();
		}
	
	public void go() {
	
		JFrame frame = new JFrame("My Window");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setUndecorated(true);
		
		Toolkit tk = Toolkit.getDefaultToolkit();
		Rectangle dim = GraphicsEnvironment.getLocalGraphicsEnvironment().getMaximumWindowBounds();
		Dimension dim1 = tk.getScreenSize();
		
		int startY = -100;
		int startX = (int) dim.getWidth() - 210;
		
		// Mac OS bug: the menubar, 20px, isn't picked up by max window bounds
		// Linux users are on their own if their DE doesn't register the top doodad.
		String os = System.getProperty("os.name").toLowerCase();
		if (os.indexOf( "mac" ) >= 0) {
			startY += 20;
		}
		
		frame.setLocation(startX, startY);
		
		JButton button = new JButton("WAZZZUPPPP!!");
		button.setFocusable(false);
		button.addActionListener(this);
		
		frame.getContentPane().add(button);
		frame.setSize(200,100);
		frame.setVisible(true);
		
		for (int i = 0; i < 110; i++) {
			frame.setLocation(startX, startY + i);
			try {Thread.sleep(16);} catch (Exception e) {}
			}
		
		}// close go() method
		
		public void actionPerformed(ActionEvent event) {
			System.exit(0);
		}
	
} // close outer class